Skip to content

fix: resolve codeformatter test failures and compilation errors#53

Merged
vuon9 merged 1 commit intomainfrom
fix/codeformatter-tests
Mar 3, 2026
Merged

fix: resolve codeformatter test failures and compilation errors#53
vuon9 merged 1 commit intomainfrom
fix/codeformatter-tests

Conversation

@vuon9
Copy link
Owner

@vuon9 vuon9 commented Mar 3, 2026

Summary

This PR fixes multiple test failures and a compilation error in the internal/codeformatter package:

  • Fixed compilation error: Variable html was shadowing the html package import in css_selector_test.go
  • Fixed test expectations: Changed literal \n to actual newline characters in test assertions
  • Fixed CSS descendant selector: Rewrote selector logic to properly respect ancestor relationships and added deduplication
  • Fixed XML attribute matching: Updated to handle attributes in any order (not just immediately after tag name)
  • Fixed nested XML extraction: Corrected test to properly count elements using slice method

Changes

New Features

  • Added support for element.class selectors (e.g., div.header)
  • Added support for double quotes in XPath expressions (e.g., //book[@id="bk101"])
  • Added proper handling for direct child (>) vs any descendant (space) selectors

Bug Fixes

  • Fixed findElementsByDescendant to properly parse and execute chained selectors
  • Fixed extractElementByAttribute to search attributes regardless of order
  • Fixed applyXPathFilter to recognize double-quoted attribute values

Test Plan

  • All Go tests pass (go test ./...)
  • CSS selector tests cover element, class, ID, descendant, and element.class selectors
  • XPath filter tests cover element selection, attribute matching, and nested paths
  • XML extraction tests properly count elements

Testing

go test ./...

All 8 test packages passing ✅

- Fix compilation error in css_selector_test.go (html package shadowing)
- Fix test expectations: change literal \n to actual newlines
- Fix CSS descendant selector to respect ancestor relationships
- Fix XML attribute matching to handle any attribute order
- Fix nested XML extraction test to properly count elements
- Add support for element.class selectors (e.g., div.header)
- Add support for double quotes in XPath expressions

All tests now passing.
@vuon9 vuon9 force-pushed the fix/codeformatter-tests branch from c2a250d to af93459 Compare March 3, 2026 09:15
@github-actions
Copy link

github-actions bot commented Mar 3, 2026

Code Coverage

Package Line Rate Health
devtoolbox/internal/barcode 90%
devtoolbox/internal/codeformatter 78%
devtoolbox/internal/converter 60%
devtoolbox/internal/datagenerator 91%
devtoolbox/internal/datetimeconverter 73%
devtoolbox/internal/jwt 42%
devtoolbox/internal/settings 0%
Summary 68% (3504 / 5175)

Minimum allowed line rate is 60%

@vuon9 vuon9 merged commit 4d8524a into main Mar 3, 2026
2 checks passed
@vuon9 vuon9 deleted the fix/codeformatter-tests branch March 3, 2026 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant